def fact(n):
    if n == 1:
        return 1
    result = n * fact(n-1)
    return result

# 循环嵌套，如果次数很多，会出现栈溢出的报错
result = fact(6)
print(result)